mui.init({
	gestureConfig: {
		longtap: true, //默认为false
	}
});
var bookshelf = new Vue({
	el: '.line',
	data: {
		books: []
	},
	updated: function() {
		$(".bookdata").on("tap", function() {
			common.open("../bookdetails/details.html", "", $(this).attr("bookuid"))
		})
		$(".bookdata").on("longtap", function() {
			heid()
			$(this).find(".remove").css("display", "block")
			$(this).find(".remove_text").css("display", "block")
		})
		$(".remove_text").on("tap", function(e) {
			var self = $(this)
			common.ajax("student/myShelf/delete", {
				uid: common.uid,
				token: common.token,
				bookUid: self.parents(".bookdata").attr("bookuid")
			}, function(data) {
				if(data.code == 200) {
					heid()
					self.parents(".bookdata").remove()
					mui.toast("成功删除")
					if($(".bookdata").length == 0) {
						/*$(".iframe").css("display", "block")
						$(".iframe_main").css("display", "none")*/
						window.parent.kong()
					}
				} else {
					mui.toast(data.message)
				}
			})
			e.stopPropagation()
		})
		$(".remove").on("tap", function(e) {

			heid()
			e.stopPropagation()
		})
		$("body").on("tap", function() {
			heid()
		})
	}
});

function heid() {
	$(".remove").css("display", "none")
	$(".remove_text").css("display", "none")
}

var pageSize = 1
mui.init({
	pullRefresh: {
		container: '#offCanvasContentScroll',
		down: {
			callback: pulldownRefresh
		},
		up: {
			contentrefresh: '正在加载...',
			callback: pullupRefresh
		}
	}
});
/**
 * 下拉刷新具体业务实现
 */
function pulldownRefresh() {
	setTimeout(function() {
		mui('#offCanvasContentScroll').pullRefresh().endPulldownToRefresh()
	}, 400)
}
/**
 * 上拉加载具体业务实现
 */
function pullupRefresh() {
	var self = this
	common.ajax("student/myShelf/queryMyShelf", {
		uid: common.uid,
		token: common.token,
		page: pageSize++,
		pageSize: "9"
	}, function(data) {
		if(data.code == 200) {
			if(!data.data.hasNextPage) {
				mui('#offCanvasContentScroll').pullRefresh().endPullupToRefresh(true)
			} else {
				mui('#offCanvasContentScroll').pullRefresh().endPullupToRefresh()
			}
			for(var i = 0; i < data.data.list.length; i++) {
				bookshelf.books.push(data.data.list[i])
			}
		} else {
			mui.toast(data.message)
		}
	}, "get")
}

if(mui.os.plus) {
	mui.plusReady(function() {
		setTimeout(function() {
			mui('#offCanvasContentScroll').pullRefresh().pullupLoading();
		}, 50);

	});
} else {
	mui.ready(function() {
		mui('#offCanvasContentScroll').pullRefresh().pullupLoading();
	});
}